package com.hunzi.domain;
/*
* 描述购物项
* */
public class CartItem {
    private Item item ; //购买的商品
    private int count ; //购买的数量
    private double subtotal ; //小计

    public CartItem() {
    }

    //构造方法是为了获得 购买的数量 和购买的商品
    public CartItem(Item item, int count   ) {
        this.item = item;
        this.count = count;

    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public double getSubtotal() {

        // 计算 该项的小计， 更新数量，小计自动更新
        subtotal = count*item.getShopPrice () ;
        return subtotal;
    }

    public void setSubtotal(double subtotal) {
        this.subtotal = subtotal;
    }

}
